package point

import (
	"os/exec"
	"strings"
)

type KernelVersionPoint struct{}

func NewKernelVersionPoint() *KernelVersionPoint { return &KernelVersionPoint{} }

func (m *KernelVersionPoint) Get() any {
	getKernelVersion := func() string {
		output, err := exec.Command("uname", "-r").Output()
		if err != nil {
			return ""
		}

		return strings.TrimSuffix(string(output), "\n")
	}

	return getKernelVersion()
}

func (m *KernelVersionPoint) Set(...any) bool { return true }

func (m *KernelVersionPoint) SetRoute(string) PointInterface { return m }
